package Java.BlackHorse.a06ThreadTest.Test4;

import java.util.ArrayList;
import java.util.Collections;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class ThreadDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ArrayList<Integer> list = new ArrayList<>();
        Collections.addAll(list,10,10,10,20,20,50,100,200);

        MyCallable mc = new MyCallable(list);
        FutureTask<Integer> ft1 = new FutureTask<>(mc);
        FutureTask<Integer> ft2 = new FutureTask<>(mc);

        Thread t1 = new Thread(ft1,"抽奖箱一");
        Thread t2 = new Thread(ft2,"抽奖箱一");

        t1.start();
        t2.start();

        System.out.println(ft1.get());
        System.out.println(ft2.get());
    }
}
